import { createBrowserRouter, redirect} from "react-router-dom";
import AppLayout from "../layout";
import Login from "@/pages/login";
import User from "@/pages/system/user";
import Role from "@/pages/system/role";
import Home from "@/pages/home";
import ProductList from "@/pages/products/list";
import ProductDetail from "@/pages/products/detail";
import MaterialList from "@/pages/material/list";
import MaterialDetail from "@/pages/material/detail";
import AuthRoute from './authRouter';
const routes = [
    { 
        path: "/", 
        element: <AuthRoute><AppLayout /></AuthRoute>,
        hidden: true,
        children:[{
            path: "/home",
            element:<Home />
        }],
        redirect: "/home"
    },
    {
        path: "/login",
        element: <Login />,
        children: []
    },
    {
        path: "/system",
        element: <AuthRoute><AppLayout /></AuthRoute>,
        children: [
            {
                path: "/system/user",
                element:<User />
            },
            {
                path: "/system/role",
                element:<Role />
            },
            {
                path: "/system/dict",
                element:<div>字典管理</div>
            }
            
        ]
    },
    {
        path: "/order",
        element: <AuthRoute><AppLayout /></AuthRoute>,
        children: [
            {
                path: "/order/list",
                element:<div>订单列表</div>
            },
            {
                path: "/order/detail/:id",
                hidden: true,
                element:<div>订单详情</div>
            },
            {
                path: "/order/afterSales",
                element:<div>售后列表</div>
            },
            {
                path: "/order/afterSalesDetail/:id",
                hidden: true,
                element:<div>售后详情</div>
            },
            {
                path: "/order/afterSalesReasons",
                element:<div>售后原因</div>
            }
        ]
    },
    {
        path: "/products",
        element: <AuthRoute><AppLayout /></AuthRoute>,
        children: [
            {
                path: "/products/list",
                element:<ProductList /> 
            },
            {
                path: "/products/detail/:id",
                hidden: true,
                element:<ProductDetail /> 
            },
            {
                path: "/products/MaterialList",
                element:<MaterialList /> 
            },
            {
                path: "/products/MaterialDetail/:id",
                hidden: true,
                element:<MaterialDetail /> 
            },

        ]
    },
    {
        path: "/customers",
        element: <AuthRoute><AppLayout /></AuthRoute>,
        children: [
            {
                path: "/customers/list",
                element:<div>客户列表</div>
            },
            {
                path: "/customers/detail/:id",
                hidden: true,
                element:<div>客户详情</div>
            }
        ]
    },
    {
        path:'/payment',
        element: <AuthRoute><AppLayout /></AuthRoute>,
        children: [
            {
                path:'/payment/list',
                element:<div>支付列表</div>
            },
        ]
    },
    // { path: "*", element: <div>404</div> }
]
const routers = createBrowserRouter(routes)

export { routes };

export default routers;